#include "Ncl.h"
#include "Context.h"
#include "Switch.h"
#include "Video.h"
#include "Sound.h"
#include "Image.h"
#include "Text.h"



bool Ncl::interpretPorts ()
{
	dbg.log(__PRETTY_FUNCTION__, "interpretting Ports...");

	MediaType media_type;

	// Looking for entry ports
	BOOST_FOREACH( string id, ncl_cache->getPorts(str_id) )
	{	
		media_type=ncl_cache->getMediaTypeFromPort(id);
		
		//dbg.log(__PRETTY_FUNCTION__, id + " -> " + to_string(media_type));
		// Starting entry port Media
		switch(media_type)
		{
			case MEDIA_NCL:
				addMedia<Ncl>(trd, id);
				break;
			case MEDIA_CONTEXT:
				addMedia<Context>(trd, id);
				break;
			case MEDIA_SWITCH:
				addMedia<Switch>(trd, id);
				break;
			case VIDEO:
				addMedia<Video>(trd, id);
				break;
			case SOUND:
				addMedia<Sound>(trd, id);
				break;
			case IMAGE:
				addMedia<Image>(trd, id);
				break;
			case TXT:
				addMedia<Text>(trd, id);
				break;
			default:
				dbg.log(__PRETTY_FUNCTION__, "Media Type[" + to_string(media_type) + "] dit not find!");
				break;
		}
	}

	dbg.log(__PRETTY_FUNCTION__, "Starting Ports...");
	startMedias();
}

bool Ncl::interpretTransition(string t)
{
	dbg.log(__PRETTY_FUNCTION__, "interpretting Transition...");
	
	string id;
	EVENT evt;
	MediaType media_type;
	ncl_cache->getMediasTransition(t,str_id);
	
/*
	// Looking for medias for this transition
	BOOST_FOREACH( vector<string> evt_media, ncl_cache->getMediasTransition(t,str_id) )
	{	
		id=evt_media[0];
		evt=evt_media[1];
		
		if(media[id]!=NULL && evt!=START)
		{
			media[id].process_event(evt);
			return true;
		}
		

		media_type=ncl_cache->getMediaType(id);		
		dbg.log(__PRETTY_FUNCTION__, evt_media[0] + " -> " + to_string(media_type));
		// Starting Media
		switch(media_type)
		{
			case MEDIA_NCL:
				addMedia<Ncl>(trd, id);
				break;
			case MEDIA_CONTEXT:
				addMedia<Context>(trd, id);
				break;
			case MEDIA_SWITCH:
				addMedia<Switch>(trd, id);
				break;
			case VIDEO:
				addMedia<Video>(trd, id);
				break;
			case SOUND:
				addMedia<Sound>(trd, id);
				break;
			case IMAGE:
				addMedia<Image>(trd, id);
				break;
			case TXT:
				addMedia<Text>(trd, id);
				break;
			default:
				dbg.log(__PRETTY_FUNCTION__, "Media Type[" + to_string(media_type) + "] dit not find!");
				break;
		}
		startMedia(id);
	}
*/
}

